﻿<!DOCTYPE html>
<html ng-app="demoApp">
<head>
    <title id="Description">Event Handling in AngularJS using jqxAngular plug-in</title>
    <link rel="stylesheet" type="text/css" href="../../jqwidgets/styles/jqx.base.css" />
    <script type="text/javascript" src="../../scripts/angular.min.js"></script>
    <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxangular.js"></script>
    <script type="text/javascript" src="../../scripts/demos.js"></script>
    <script type="text/javascript">
        var demoApp = angular.module("demoApp", ["jqwidgets"]);
        demoApp.controller("demoController", function ($scope) {
            $scope.people = [{
                id: 1,
                name: "Nancy",
                age: 52
            }, {
                id: 2,
                name: "Andrew",
                age: 31
            }, {
                id: 3,
                name: "Robert",
                age: 40
            }, {
                id: 4,
                name: "Peter",
                age: 28
            }];

       
            // init DropDownList's settings object.
            $scope.dropDownListSettings =
            {
                width: 200,
                height: 30,
                autoDropDownHeight: true,
                displayMember: "name",
                valueMember: "id",
                source: $scope.people,
                // change event with callback.
                change: function (event) {
                    var time = new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds();
                    $scope.changeEventLog = 'Event Name ' + time + ' change';
                }
            }

            $scope.changeEventLog = "";
            $scope.selectEventLog = "";
            $scope.unselectEventLog = "";
            $scope.createdEventLog = "";

            // listen to 'select' event using callback function.
            $scope.selectHandler = function (event) {
                var time = new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds();
                $scope.selectEventLog = 'Event Name ' + time + ' select';
            }

            // listen to 'unselect' event using $on.
            $scope.$on('unselect', function (event, arguments) {
                var time = new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds();
                $scope.unselectEventLog = 'Event Name ' + time + ' unselect';
            });

            // listen to jqxDropDownListCreated event.
            $scope.$on('jqxDropDownListCreated', function (event, arguments) {
                var time = new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds();
                $scope.createdEventLog = 'Event Name ' + time + ' jqxDropDownListCreated';
            });
        });
    </script>
</head>
<body>
    <div ng-controller="demoController">
        <jqx-drop-down-list jqx-on-unselect="unselect" jqx-on-select="selectHandler(event)" jqx-settings="dropDownListSettings"></jqx-drop-down-list>
        <br />
        <div>{{createdEventLog}}</div>
        <div>{{unselectEventLog}}</div>
        <div>{{selectEventLog}}</div>
        <div>{{changeEventLog}}</div>
    </div>
</body>
</html>
